<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-08-08 17:00
 *
 * Version: 2.0
 */

namespace App\Modules\Order\Transformers;


use League\Fractal\TransformerAbstract;

class GetScheduleAppTransformer extends TransformerAbstract
{
	private $list;
	public function __construct($list)
	{
		$this->list = $list;
	}


	public function transform(){
		return array_map(function ($v){
			$dateArr = explode('-',$v['date']);
			return [
				'day' => $dateArr[2],
				'month'=>$dateArr[1],
				'year' =>$dateArr[0],
				'selectable' => config('constant.scheduleStatus.selectable') == $v['status'] ? 1 : 0,
				'rest' => config('constant.scheduleStatus.rest') == $v['status'] ? 1 : 0,
				'appointment' => config('constant.scheduleStatus.appointment') == $v['status'] ? 1 : 0,
				'today' => $v['date'] == date('Y-m-d',time()) ? 1 : 0,
			];
		},$this->list['list']);
	}
}